<?php
/**
 * Created by PhpStorm.
 * User: fengyan
 * Date: 2017/10/15
 * Time: 上午10:38
 */

namespace App\Http\Controllers\Admin;


use App\Exceptions;
use Illuminate\Http\Request;
use App\Helpers;

class ApiController
{
    use Helpers\Jump;

    /**
     * 后台公共Api接口
     * @param Request $request
     * @return mixed
     * @throws Exceptions\MyException
     */
    public function index(Request $request)
    {
        $method = $request->route('method', '');

        if (empty($method)) {
            throw new Exceptions\MyException("后台公共Api接口方法不能为空", -1);
        }

        if (method_exists($this, $method)) {
            throw new Exceptions\MyException("后台公共Api接口方法不存在", -1);
        }

        return $this->$method($request);
    }

    
}